//
//  CreateJobReviewTopView.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/6/13.
//

import UIKit
import SnapKit
import RxSwift
import RxCocoa
class CreateJobReviewTopView: View {
    lazy var disposeBag = DisposeBag()
    let contentLabel = ContentLabel(R.font.interSemiBold(size: 15))
    
    override func setUpView() {
        //imageView
        let imageView = UIImageView(image: R.image.createjob_review_top_panel())
        self.addSubview(imageView)
        imageView.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.centerX.equalToSuperview()
            make.height.width.equalTo(37)
            
        }
        
        //titleView
        self.addSubview(contentLabel)
        contentLabel.snp.makeConstraints { make in
            make.top.equalTo(imageView.snp.bottom).offset(15)
            make.centerX.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)
            make.bottom.equalTo(-10)
        }
        CreateJobModelHelper.shared.systemInfoObserver.map({$0.rec_quantity}).subscribe(onNext: { [weak self] stcs in
            guard let strongSelf = self else { return  }
            var stcFormat = stcs
            if let data = Int(stcs) {
                let formatStcs = Tool().formatAmountToStr(amount: stcs, maximumFractionDigits: 0,minimumFractionDigits: 0)
                stcFormat = formatStcs
            }
            strongSelf.contentLabel.text = stcFormat + " STCs @ " + CreateJobModelHelper.shared.createJobViewModel.systemDetail.total_panes_watts_format + " kW"
        }).disposed(by: self.disposeBag)
    }
}
